home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / fstab / fstab.c < prev    next >
C/C++ Source or Header  |  1996-03-01  |  2KB  |  93 lines

  1. #pragma implementation
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <stdarg.h>
  6. #include "fstab.h"
  7. #include "../xconf/xconf.h"
  8. #include "../userconf/userconf.h"
  9. #include "../netconf/netconf.h"
  10. #include "fstab.m"
  11.  
  12. static FSTAB_HELP_FILE help_access ("access");
  13.  
  14. void fstab_edit()
  15. {
  16.     /* #Specification: netconf / principal
  17.         The user must select one of these choice
  18.  
  19.         bla bla
  20.     */
  21.     int choice=0;
  22.     while (1){
  23.         static const char *local_partition = MSG_U(M_LOCALD,"local drive");
  24.         static const char *remote_nfs = MSG_U(M_NFSVOL,"nfs volume");
  25.         static const char *samba_fs   = MSG_U(M_SAMBA,"samba volume (WfWg)");
  26.         static const char *swap_volume = MSG_U(M_SWAP,"swap files and partitions");
  27.         static const char *fixperm = MSG_U(M_FIXPERM,"some file permissions");
  28.         static const char *menuopt[]={
  29.             MSG_U(M_ACCESS,"Access"),        local_partition,
  30.             " ",                            remote_nfs,
  31.             " ",                            samba_fs,
  32.             MSG_U(M_CONFIGURE,"Configure"),    swap_volume,
  33.             "-",        "",
  34.             MSG_U(M_CHECK,"Check"),            fixperm,
  35.             NULL
  36.         };
  37.         MENU_STATUS code = xconf_menu (
  38.             MSG_U(T_FSCONF,"Filesystem configurator")
  39.             ,MSG_U(I_FSCONF,"This package allows you to configure\n"
  40.              "which partition and network volume your workstation\n"
  41.              "can access")
  42.             ,help_access
  43.             ,menuopt,choice);
  44.         if (code == MENU_QUIT || code == MENU_ESCAPE){
  45.             break;
  46.         }else{
  47.             const char *key = menuopt[choice*2+1];
  48.             if (key == local_partition){
  49.                 fstab_edit (FSTAB_ENTRY_LOCAL);
  50.             }else if (key == remote_nfs){
  51.                 fstab_edit (FSTAB_ENTRY_NFS);
  52.             }else if (key == samba_fs){
  53.                 xconf_notice (MSG_U(N_NOSAMBA
  54.                     ,"Samba management not available\n"
  55.                     "at this time"));
  56.             }else if (key == swap_volume){
  57.                 fstab_edit (FSTAB_ENTRY_SWAP);
  58.             }else if (key == fixperm){
  59.                 if (perm_rootaccess (
  60.                     MSG_U(P_FIXPERM,"To fix file permission"))){
  61.                     simul_init();
  62.                     fixperm_check();
  63.                     int ok = simul_prompt();
  64.                     if (ok==1){
  65.                         fixperm_check();
  66.                     }else if (ok == -1){
  67.                         xconf_notice (MSG_U(N_ALLISOK,"All is ok"));
  68.                     }
  69.                 }
  70.             }
  71.         }
  72.     }
  73. }
  74.  
  75. int fstab_main(int argc, char *argv[])
  76. {
  77.     if (argc == 1){
  78.         fstab_edit();
  79.     }else if (argc == 2 && strcmp(argv[1],"--check")==0){
  80.         fstab_check();
  81.     }else{
  82.         xconf_error (
  83.             MSG_U(E_FSTABARG
  84.                 ,"Invalid argument\n\n"
  85.                  "fsconf<enter>\n"
  86.                  "fsconf --check<enter>\n")
  87.             );
  88.     }
  89.     return 0;
  90. }
  91.  
  92.  
  93.